package com.tony.study.designMode.DM3_单例模式;

/**
 * Created with IntelliJ IDEA.
 *
 * @Title: Singleton4
 * @Auther: 皮蛋布丁
 * @Date: 2021/11/01/16:35
 * @Description: 单例模式（内部静态类工厂类提前创建好实例对象）
 */
public class Singleton4 {

    //私有构造器，防止外部new实例
    public Singleton4() {
    }
    private static class SingletonFactory {
        private static Singleton4 instance = new Singleton4();
    }

    public static Singleton4 getInstance() {
        return SingletonFactory.instance;
    }
    public void show() {
        System.out.println("你好，我是静态内部类单例模式！");
    }
}
